Validator = {
    validate: function (selector) {
        $(selector).bootstrapValidator('validate');//提交验证
    },
    new: function (selector, submitBtn, fields, succCall) {
        /**
         * 下面是进行插件初始化
         * 你只需传入相应的键值对
         * */
        $(selector).bootstrapValidator({
            feedbackIcons: {/*输入框不同状态，显示图片的样式*/
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: fields
        }).on('success.form.bv', function (e) {
            // Prevent form submission
            e.preventDefault();

            succCall()
        });

        $(submitBtn).click(function(){
            Validator.validate(selector)
        });
    },
    newDomainName: function (succCall) {
        Validator.new('.box-body','#add-domain-btn', {
            name: {/*键名username和input name值对应*/
                validators: {
                    notEmpty: {/*非空提示*/
                        message: '域名地址不能为空'
                    }
                }
            },
            domain_name: {
                validators: {
                    regexp: { //正则表达式
                        regexp: /^[a-z_]{0,30}$/,
                        message: '只能包含小写和下划线,30位'
                    }
                }
            }
        }, succCall)
    },
    newService: function (succCall) {
        Validator.new('.box-body', '#add-service-btn',{
            name: {/*键名username和input name值对应*/
                validators: {
                    notEmpty: {/*非空提示*/
                        message: '服务模块名称不能为空'
                    },
                    regexp: { //正则表达式
                        regexp: /^[a-z_]{0,30}$/,
                        message: '只能包含小写和下划线,30位'
                    }
                }
            }
        }, succCall)
    }
}